package com.star.uc.biz;

import cn.dev33.satoken.stp.StpUtil;
import com.star.common.core.contract.exception.ServiceException;
import com.star.uc.contract.enums.UserErrorEnum;
import com.star.uc.contract.param.UserInfoParam;
import com.star.uc.contract.query.UserInfoQuery;
import com.star.uc.infras.repository.model.UserInfoBO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 用户查询业务
 *
 * @author zhouhengzhe
 */
@Service
@RequiredArgsConstructor
public class UserQueryBizService {

    /**
     * 获取用户个人信息
     *
     * @return userInfoBO 用户信息
     */
    public UserInfoBO info(UserInfoQuery userInfoQuery) {
        if (!StpUtil.isLogin()) {
            throw new ServiceException(UserErrorEnum.USER_NOT_LOGIN);
        }
        //通过uid去获取用户信息
        return UserInfoParam.builder().uid(userInfoQuery.getUid()).build().one();
    }


}
